#include "vicsek.h"
#include "rendering.h"
#include <ctime>
using namespace std;

Vicsek vicsek(500,20,100,30);
Vicsek vicsek2(600,20,100,30);
float Alpha = 0.05;
float Beta = 1;
float Gamma = 1;

void ScanPhaseSpace()
{
    int STEPS = 2000;
//    //remaining time estimation
    clock_t start = clock();
    vicsek.Init();
    for (int i = 0; i <STEPS; i++)
    {
        vicsek.Simulate(Alpha, Beta, Gamma);
    }
    clock_t end = clock();
    vicsek.ClearMemory();
    float singletime = (float)(end-start)/1000000;
    for (int i = 1; i < 11; i++)
    {
        for (int j = 1; j < 11; j++)
        {
            Alpha = 0.05*pow((float)2,float(i));
            Gamma = 0.05*pow((float)2, float(j));
            int curdir = CreateFolder( 5 );
            vicsek.CreateParFile(curdir, Alpha, Beta, Gamma);
            cout<<"Processing "<<curdir<<" files. "<<"Completed "<<(float)curdir/100*100<<"%"<<endl;
            cout<<"Remaining time "<<5*(100 - curdir)*singletime<<"s"<<endl;
            for (int k = 1; k<=5; k++)
            {
                vicsek.Init();
                for(int step = 1; step < STEPS; step++)
                {
                    vicsek.Simulate(Alpha, Beta, Gamma);
                    vicsek.CreateFile( curdir, k, step );
                }
                vicsek.ClearMemory();
            }
        }
    }
}

int main(int argc, char** argv)
{
    ScanPhaseSpace();
    //CreateFolder( 5 );
//	vicsek2.Init();
//    vicsek.Init();
//	clock_t start = clock();
//	for (int i = 0; i <2000; i++)
//		{
//			vicsek.Simulate(Alpha, Beta, Gamma);
//		}
//	clock_t end = clock();
//	cout<<(float)(end-start)/1000<<endl;

    //rendering(argc, argv);
    return 0;
}

